package com.kai.demo.service.impl;

import com.kai.demo.dao.UserDao;
import com.kai.demo.entity.User;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

/**
 * <p>Project: sprigncloud-demo </p>
 * <p>Description: </p>
 * <p>Copyright (c) 2024 Karrytech (Shanghai/Beijing) Co., Ltd.</p>
 * <p>All Rights Reserved.</p>
 *
 * @author <a href="mailto:zhangkai@karrytech.com">Zhang Kai</a>
 */
@Service
public class UserServiceImpl implements com.kai.demo.service.UserService {

    private final Logger logger = Logger.getLogger(this.getClass());

    @Resource
    private UserDao userDao;

    public void save(User user) {
        userDao.save(user);
    }

    public User get(BigInteger id) {
        try {
            return userDao.getById(id);
        } catch (Exception e){
            logger.info("数据查找失败！");
            return new User();
        }
    }

    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }
}